home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / distress-selection.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  3.1 KB  |  103 lines

  1. ;
  2. ; distress selection
  3. ;
  4. ;
  5. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  6. ; At ECS Dept, University of Southampton, England.
  7.  
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ; GNU General Public License for more details.
  16. ; You should have received a copy of the GNU General Public License
  17. ; along with this program; if not, write to the Free Software
  18. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. ; Define the function:
  21.  
  22. (define (script-fu-distress-selection inImage
  23.                       inLayer
  24.                       inThreshold
  25.                       inSpread
  26.                       inGranu
  27.                       inSmooth
  28.                       inSmoothH
  29.                       inSmoothV)
  30.  
  31.   (set! theImage inImage)
  32.   (set! theWidth (car (gimp-image-width inImage)))
  33.   (set! theHeight (car (gimp-image-height inImage)))
  34.  
  35.   (gimp-image-undo-group-start theImage)
  36.  
  37.   (set! theLayer (car (gimp-layer-new theImage
  38.                       theWidth
  39.                       theHeight
  40.                       RGBA-IMAGE
  41.                       "Distress Scratch Layer"
  42.                       100
  43.                       NORMAL-MODE)))
  44.  
  45.   (gimp-image-add-layer theImage theLayer 0)
  46.  
  47.   (if (= TRUE (car (gimp-selection-is-empty theImage)))
  48.       ()
  49.       (gimp-edit-fill theLayer BACKGROUND-FILL))
  50.  
  51.   (gimp-selection-invert theImage)
  52.  
  53.   (if (= TRUE (car (gimp-selection-is-empty theImage)))
  54.       ()
  55.       (gimp-edit-clear theLayer))
  56.  
  57.   (gimp-selection-invert theImage)
  58.   (gimp-selection-none inImage)
  59.  
  60.   (gimp-layer-scale theLayer
  61.             (/ theWidth inGranu)
  62.             (/ theHeight inGranu)
  63.             TRUE)
  64.  
  65.   (plug-in-spread TRUE
  66.           theImage
  67.           theLayer
  68.           inSpread
  69.           inSpread)
  70.  
  71.   (plug-in-gauss-iir TRUE theImage theLayer inSmooth inSmoothH inSmoothV)
  72.   (gimp-layer-scale theLayer theWidth theHeight TRUE)
  73.   (plug-in-threshold-alpha TRUE theImage theLayer inThreshold)
  74.   (plug-in-gauss-iir TRUE theImage theLayer 1 TRUE TRUE)
  75.   (gimp-selection-layer-alpha theLayer)
  76.   (gimp-image-remove-layer theImage theLayer)
  77.  
  78.   (gimp-image-undo-group-end theImage)
  79.  
  80.   (gimp-displays-flush))
  81.  
  82.  
  83. (script-fu-register "script-fu-distress-selection"
  84.             _"_Distress Selection..."
  85.             "No description"
  86.             "Chris Gutteridge"
  87.             "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  88.             "23rd April 1998"
  89.             "RGB*"
  90.             SF-IMAGE       "The image"              0
  91.             SF-DRAWABLE    "The layer"              0
  92.             SF-ADJUSTMENT _"Threshold (bigger 1<-->255 smaller)" '(127 1 255 1 10 0 0)
  93.             SF-ADJUSTMENT _"Spread"                 '(8 0 1000 1 10 0 1)
  94.             SF-ADJUSTMENT _"Granularity (1 is low)" '(4 1 25 1 10 0 1)
  95.             SF-ADJUSTMENT _"Smooth"                 '(2 0 150 1 10 0 1)
  96.             SF-TOGGLE     _"Smooth horizontally"    TRUE
  97.             SF-TOGGLE     _"Smooth vertically"      TRUE)
  98.  
  99. (script-fu-menu-register "script-fu-distress-selection"
  100.              _"<Image>/Script-Fu/Selection")
  101.